<template>
  <div class="box">
    <div class="left">
      <!-- <leftbar /> -->
      <van-sidebar v-model="activeKey">
        <van-sidebar-item title="所有分类" @click="suoyou" />
        <van-sidebar-item
          :title="item.name"
          v-for="(item, index) in copylist"
          :key="index"
          @click="shuma(item.id)"
        />
      </van-sidebar>
    </div>
    <div class="right">
      <div class="ringhtscroll">
        <div class="righttop"><Rotation /></div>
        <div class="rightbuttom">
          <div class="box2">
            <span
              class="sp1"
              v-for="(item, index) in list"
              :key="index"
              @click="gofenleiproduct(item)"
            >
              <img :src="item.icon" alt="" />
              <p>{{ item.name }}</p>
            </span>
          </div>
        </div>
      </div>
       <div class="deng"></div>
    </div>

    <!-- <van-row>
      <van-col span="8"><div class="left">
      <leftbar />
    </div></van-col>
      <van-col span="16"
        ><div class="righttop"><Rotation /></div>
        <div class="rightbuttom">
          <alllist /></div
      ></van-col>
    </van-row> -->
   
  </div>
</template>

<script>

import Rotation from "../../components/ifcation/Rotation";

export default {
  data() {
    return {
      activeKey: 0,
      list: [],
      copylist: [],
      lists: [],
    };
  },
  components: {
    // leftbar,
    Rotation,
    // alllist,
  },
  methods: {
    gofenleiproduct(item) {
      this.$router.push({ path: "/branchProduct", query: { item } });
    },

    suoyou() {
      this.list = this.lists;
    },

    shuma(id) {
      var res = this.lists.filter((item) => {
        if (item.pid == id) {
          // console.log(id);
          return item;
        }
      });
      this.list = res;
      // console.log(456);
    },

    feng() {
      this.$API.fenleileft().then((res) => {
        this.list = res.data.data;
      });
    },
  },
  mounted() {
    this.$API.fenleileft().then((res) => {
      // this.list = res.data.data;
      this.lists = res.data.data;
      // this.copylist = res.data.data;
      this.list = this.lists;
      console.log(res.data.data);
      this.copylist = this.lists.filter((item) => {
        if (item.pid == "0") {
          return item;
        }
      });

      // console.log(copylist);
    });
    this.suoyou();
  },
};
</script>

<style lang="scss" scoped>
.deng{
    width: 100%;
    height: 3rem;
    // background: red;
}
.box {
  width: 100%;
  margin: 0 auto;
  margin-top: 15%;
  display: flex;

  .left {
    width: 20%;
    // height: 100vh;
    // margin: 0 auto;
  }
  .right {
    width: 80%;
    // height: 100vh;
    // height: 1rem;
  }
  .ringhtscroll {
    // overflow-y: scroll;
  }
  .righttop {
    width: 80%;
    height: 2rem;
    margin: 0 auto;
  }
  .rightbuttom {
    width: 100%;
    margin: 0 auto;
    margin-top: 3rem;
    .box2 {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-evenly;
      // margin-top: 3rem;
    }
    .sp1 {
      width: 30%;
      margin-top: 0.2rem;
      margin-left: 0.2rem;
      text-align: center;
      img {
        // width: 95%;
        // height: 80%;
        width: 2.2rem;
        height: 2.2rem;
      }
      p {
        font-size: 0.32rem;
        margin-top: 0.1rem;
      }
    }
  }
}
</style>